package com.atguigu.srb.core.controller.api;

import com.atguigu.srb.common.result.Result;
import com.atguigu.srb.core.service.IntegralGradeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * @author lsyandwh
 * @create 2022-12-16 11:52
 */
@Api(tags = "用户积分额度")
@RestController
@RequestMapping("/api/core/integralGrade")
public class ApiIntegralGradeController {

    @Autowired
    private IntegralGradeService integralGradeService;

    @ApiOperation("获取借款额度")
    @GetMapping("/getIntegral")
    public Result getIntegral(HttpServletRequest request){

        String usrId = request.getHeader("userId");

        BigDecimal borrowAmount = integralGradeService.getIntegralByUserId(usrId);

        return Result.ok().data("borrowAmount",borrowAmount.doubleValue());
    }

}
